<template>
  <el-dialog
    title="选择员工"
    :visible.sync="visible"
    width="65%"
    top="5vh"
    :before-close="handleClose"
  >
    <!-- 查询模块 -->
    <searchform
      @f_search="f_search"
      tablid="9"
      module="chooseWorker-search"
    ></searchform>
    <!-- 列表模块 -->
    <list ref="tableData" tableId="9" module="personalBasicInformation"></list>

    <span slot="footer" class="dialog-footer">
      <el-button size="small" @click="handleClose">取 消</el-button>
      <el-button size="small" type="primary" @click="chooseSubmit"
        >确 定</el-button
      >
    </span>
  </el-dialog>
</template>
<script>
import api from "@/api/test";
import list from "@/views/system/common/chooseList.vue";
import searchform from "@/views/system/common/searchForm";
export default {
  name: "ChoosePerson",
  components: {
    list,
    searchform,
  },
  props: {
    visible: {
      //控制弹窗，true就弹出
      type: Boolean,
      default: false,
    },
    remoteClose: Function, //用于关闭窗口
  },
  data() {
    return {
      chooseRow: {},
    };
  },
  methods: {
    f_search(dto) {
      this.$refs.tableData.f_search(dto);
    },
    async chooseSubmit() {
      this.chooseRow = this.$refs.tableData.chooseRow;
      console.log(this.chooseRow);
      if (JSON.stringify(this.chooseRow) == "{}") {
        this.$message.error("请先选中一条数据");
        return;
      } else {
        const params = {
          aac001: this.chooseRow.aac001,
        };
        const res = await api.queryBody(
          "/admin/api/bfmc/BasicInformationModificationController/chooseAstaff",
          params
        );
        if (res.code == 1) {
          this.$parent.getInputAndList(res.data);
        } else {
          this.$message.error(res.msg);
        }
      }
    },
    // 关闭窗口
    handleClose() {
      this.remoteClose();
    },
  },
};
</script>
